package com.java.collection;

public class Student implements Comparable<Student>{
	private String name; 
	private int age;
	public Student(){
		super();
	}
	public int getAge() {
		return age;
	}

	public String getName() {
		return name;
	}

	public Student(String name,int age){
		super();
		this.name=name;
		this.age=age;

	}
	public String toString(){
		return this.name+":"+this.age;
	}
	
	@Override
	public int hashCode(){
		return this.name.hashCode()^this.age^1000000;
	}
	
	@Override
	public boolean equals(Object obj){
		if(obj instanceof Student){
			Student s=(Student)obj;
			if(this.name.equals(s.name)&&this.age==s.age){
				return true;
			}
		}
		return false;
	}
	
	@Override
	public int compareTo(Student stu) {
		return this.age-stu.age;
	}


}
